package controller

import (
	"mini-app/internal/app/web/service"
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type PublishDevice struct{}

// 投放设备组列表
func (PublishDevice) PublishDeviceGroupList(c *gin.Context) {
	var params service.PublishDeviceGroupListReq
	c.ShouldBindBodyWith(&params, binding.JSON)
	data, _ := service.PublishDevice{}.PublishDeviceGroupList(c.Request.Context(), params)
	c.JSON(http.StatusOK, gin.H{
		"code": data.Code,
		"msg":  data.Msg,
		"data": data.Data,
	})
}

// 投放设备组新增编辑
func (PublishDevice) PublishDeviceGroupSave(c *gin.Context) {
	var params service.PublishDeviceGroupSaveReq
	c.ShouldBindBodyWith(&params, binding.JSON)
	data, _ := service.PublishDevice{}.PublishDeviceGroupSave(c.Request.Context(), params)
	c.JSON(http.StatusOK, gin.H{
		"code": data.Code,
		"msg":  data.Msg,
		// "data": data.Data,
	})
}

// 投放设备组删除
func (PublishDevice) PublishDeviceGroupDelete(c *gin.Context) {
	var params service.PublishDeviceGroupDeleteReq
	c.ShouldBindBodyWith(&params, binding.JSON)
	data, _ := service.PublishDevice{}.PublishDeviceGroupDelete(c.Request.Context(), params)
	c.JSON(http.StatusOK, gin.H{
		"code": data.Code,
		"msg":  data.Msg,
		// "data": data.Data,
	})
}

// 投放设备组配置设备
func (PublishDevice) PublishDeviceGroupManage(c *gin.Context) {
	var params service.PublishDeviceGroupManageReq
	c.ShouldBindBodyWith(&params, binding.JSON)
	data, _ := service.PublishDevice{}.PublishDeviceGroupManage(c.Request.Context(), params)
	c.JSON(http.StatusOK, gin.H{
		"code": data.Code,
		"msg":  data.Msg,
		// "data": data.Data,
	})
}

// 投放设备组设备列表
func (PublishDevice) PublishDeviceList(c *gin.Context) {
	var params service.PublishDeviceListReq
	c.ShouldBindBodyWith(&params, binding.JSON)
	data, _ := service.PublishDevice{}.PublishDeviceList(c.Request.Context(), params)
	c.JSON(http.StatusOK, gin.H{
		"code": data.Code,
		"msg":  data.Msg,
		"data": data.Data,
	})
}
